#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2020/1/7 08:27|08:27
# @Author  : yangdingyi
# @File    : 1309. 解码字母到整数映射
# @Software: PyCharm


class Solution:
    def freqAlphabets(self, s: str) -> str:
        ss = s.split('#')
        ls = len(ss)

        def n2c(n):
            return chr(ord('a')+int(n)-1)

        def nn2s(nn):
            return ''.join(map(n2c, nn))
        ans = ''
        for i, si in enumerate(ss):
            if not si:
                continue
            if i == ls - 1:
                ans += nn2s(si)
            elif len(si) > 2:
                if i == ls-1:
                    ans += nn2s(si)
                else:
                    ans += nn2s(si[:-2])
                    ans += n2c(si[-2:])
            else:
                ans += n2c(si)
        return ans


def main():

    data = [
        "10#11#12",
        "1326#",
        "25#",
        "12345678910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#",
    ]
    solve = Solution()

    for ii, s in enumerate(data):
        print(f'problem#{ii}', s)
        print(solve.freqAlphabets(s))


if __name__ == '__main__':
    main()
